﻿using MDT.LifeSewagePlatform.Conmmon;
using MDT.LifeSewagePlatform.InterfaceService;
using MDT.LifeSewagePlatform.Entity;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System.Threading.Tasks;

namespace MDT.LifeSewagePlatform.ServiceInstance.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [Route("api/placeduty")]
    [ApiController]
    [Authorize]
    public class PlaceDutyController :BaseController
    {
        #region ctor and prop
        [Autowired]
        private  IPlaceDutyService _placedutyService { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public PlaceDutyController()
        {
        }
        #endregion 

        #region method service
        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [CustomActionFilter(Role = RoleType.Admin)]
        public async Task<BaseMessage> Add([FromForm]AddPlaceDuty model)
        {
            return  await _placedutyService.Add(model,GetUserID());
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPut("{id}")]
        [CustomActionFilter(Role = RoleType.Admin)]
        public async Task<BaseMessage> Update(int id,[FromForm]UpdatePlaceDuty model)
        {
            return await _placedutyService.Update(model, id, GetUserID());
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Params"></param>
        /// <returns></returns>

        [HttpGet()]
        [CustomActionFilter(Role = RoleType.Admin)]
        public async Task<BaseMessage> GetPlaceDuty([FromQuery]PlaceDutyParameter Params)
        {
            return await _placedutyService.GetPlaceDutys(Params);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete("{id}")]
        [CustomActionFilter(Role=RoleType.Admin)]
        public async Task<BaseMessage> Delete(int id)
        {
            return await _placedutyService.Delete(id);
        }
        #endregion

    }
}
